projects
/
babl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
91f33cd
)
babl: always end strncpy strings with NUL
author
Tobias Stoeckmann
<tobias@stoeckmann.org>
Fri, 13 Oct 2017 17:25:01 +0000
(19:25 +0200)
committer
Øyvind Kolås
<pippin@gimp.org>
Sat, 14 Oct 2017 18:20:48 +0000
(20:20 +0200)
The function strncpy(3) does not guarantee to end the destination string
with NUL character if not enough space was available. This could happen
on systems which allow paths which are longer than 4096 characters.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
babl/babl-cache.c
patch
|
blob
|
history
diff --git
a/babl/babl-cache.c
b/babl/babl-cache.c
index fa3f3879acd99eea123305f3f58395e6953bb47d..4954e4ba983de8a5e73d7c89fdb4f90281e86f9c 100644
(file)
--- a/
babl/babl-cache.c
+++ b/
babl/babl-cache.c
@@
-37,6
+37,7
@@
mk_ancestry_iter (const char *path)
{
char copy[4096];
strncpy (copy, path, 4096);
+ copy[sizeof (copy) - 1] = '\0';
if (strrchr (copy, '/'))
{
*strrchr (copy, '/') = '\0';
@@
-63,6
+64,7
@@
mk_ancestry (const char *path)
{
char copy[4096];
strncpy (copy, path, 4096);
+ copy[sizeof (copy) - 1] = '\0';
#ifdef _WIN32
for (char *c = copy; *c; c++)
if (*c == '\\')
@@
-77,6
+79,7
@@
static const char *fish_cache_path (void)
static char path[4096];
strncpy (path, FALLBACK_CACHE_PATH, 4096);
+ path[sizeof (path) - 1] = '\0';
#ifndef _WIN32
if (getenv ("XDG_CACHE_HOME"))
sprintf (path, "%s/babl/babl-fishes", getenv("XDG_CACHE_HOME"));